package com.molichuxing.gateway.bff.statistics.convertor;

import com.molichuxing.framework.utils.DateUtil;
import com.molichuxing.gateway.bff.car.entity.response.CarCheckVo;
import com.molichuxing.gateway.bff.statistics.entity.response.AssetCountVo;
import com.molichuxing.services.property.StatisticsAssetInStockTypeEnum;
import com.molichuxing.services.property.StatisticsAssetRentalTypeEnum;
import com.molichuxing.services.property.StatisticsAssetRollbackOverdueTypeEnum;
import com.molichuxing.services.property.StatisticsAssetUseTypeEnum;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * @author liyg
 * 数据转换类
 * 2019-08-16
 */
public class Convert {
    //车辆检验
    public static AssetCountVo toAssetCountVo(Map<Integer, Integer> statisticsAssetCount) {
        LocalDateTime firstDayOfMonth = DateUtil.getDayStart(DateUtil.firstDayOfMonth(LocalDateTime.now().minusMonths(1)));
        LocalDateTime lastDayOfMonth = DateUtil.getDayEnd(DateUtil.lastDayOfMonth(LocalDateTime.now().minusMonths(1)));
        AssetCountVo voDto = new AssetCountVo();
        voDto.setStatisticsStartTime(firstDayOfMonth);
        voDto.setStatisticsEndTime(lastDayOfMonth);
        if (statisticsAssetCount != null && statisticsAssetCount.size() > 0) {
            voDto.setRental(statisticsAssetCount.get(StatisticsAssetUseTypeEnum.RENTAL.getValue()));
            voDto.setFullBuyOut(statisticsAssetCount.get(StatisticsAssetRentalTypeEnum.FULL_BUY_OUT.getValue()));
            voDto.setOperatingVehicle(statisticsAssetCount.get(StatisticsAssetRentalTypeEnum.OPERATING_VEHICLE.getValue()));
            voDto.setRollbackVehicle(statisticsAssetCount.get(StatisticsAssetRentalTypeEnum.ROLLBACK_VEHICLE.getValue()));
            voDto.setSecondaryOperations(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.SECONDARY_OPERATIONS.getValue()));
            voDto.setSell(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.SELL.getValue()));
            voDto.setInStock(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.IN_STOCK.getValue()));
            voDto.setInStockActuallyInStock(statisticsAssetCount.get(StatisticsAssetInStockTypeEnum.IN_STOCK_ACTUALLY_INSTOCK.getValue()));
            voDto.setInRoadVehicle(statisticsAssetCount.get(StatisticsAssetInStockTypeEnum.IN_ROAD_VEHICLE.getValue()));
            voDto.setInStockInLawsuit(statisticsAssetCount.get(StatisticsAssetInStockTypeEnum.IN_STOCK_IN_LAWSUIT.getValue()));
            voDto.setAbandonedVehicle(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.ABANDONED_VEHICLE.getValue()));
            voDto.setLoseVehicle(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.LOSE_VEHICLE.getValue()));
            voDto.setOverdueAndSpecial(statisticsAssetCount.get(StatisticsAssetRentalTypeEnum.OVERDUE_AND_SPECIAL.getValue()));
            voDto.setStayBackVehicle(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.STAY_BACK_VEHICLE.getValue()));
            voDto.setOverdueAndSpecialInLawsuit(statisticsAssetCount.get(StatisticsAssetRollbackOverdueTypeEnum.OVERDUE_AND_SPECIAL_IN_LAWSUIT.getValue()));
            voDto.setBulkSales(statisticsAssetCount.get(StatisticsAssetUseTypeEnum.BULK_SALES.getValue()));
            voDto.setActuallyInStock(statisticsAssetCount.get(StatisticsAssetUseTypeEnum.ACTUALLY_IN_STOCK.getValue()));
            voDto.setOfficialVehicle(statisticsAssetCount.get(StatisticsAssetUseTypeEnum.OFFICIAL_VEHICLE.getValue()));
        }
        return voDto;
    }

}
